export const mixinHighLight = function(str, keywords) {
  if (typeof str !== 'string') return ''
  if (!keywords) return str
  const reg = new RegExp(keywords, 'g')
  return str.replace(reg, `<span style="color: red;">${keywords}</span>`)
}

export const infinite = {
  // 是否显示  没有更多数据了
  noMore: {
    get() {
      return !this.loading && this.total <= (this.page - 1) * this.size && this.total > 0
    }
  },
  // 是否禁用上拉加载
  disabledScroll: {
    get() {
      return this.loading || this.total <= (this.page - 1) * this.size
    }
  },
  // 数据是否为空
  empty: {
    get() {
      return this.total === 0 && !this.loading
    }
  }
}
